home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / libs / x / xview / xview3.004 / xview3 / usr / openwin / include / xview_private / primal.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-29  |  2.1 KB  |  94 lines

  1. /*      @(#)primal.h 20.17 93/06/28 SMI      */
  2.  
  3. /*
  4.  *    (c) Copyright 1989 Sun Microsystems, Inc. Sun design patents 
  5.  *    pending in the U.S. and foreign countries. See LEGAL NOTICE 
  6.  *    file for terms of the license.
  7.  */
  8.  
  9. #ifndef primal_DEFINED
  10. #define primal_DEFINED
  11.  
  12. #include <xview_private/i18n_impl.h>
  13. #include <xview_private/portable.h>
  14.  
  15. #                        ifndef sunwindow_sun_DEFINED
  16. #include <xview/sun.h>
  17. #                        endif
  18. #                        ifndef makedev
  19. #include <sys/types.h>
  20. #                        endif
  21.  
  22. #ifdef lint
  23. #define    LINT_IGNORE(arg)
  24. #else
  25. #define    LINT_IGNORE(arg)    arg
  26. #endif
  27.  
  28. #define EOS        '\0'
  29.     /* End Of String */
  30. #define EQ        ==
  31.     /* Avoids typo making test into assignment */
  32.  
  33. #define NEW(type)    (type *) calloc(1, sizeof(type))
  34.  
  35. #ifndef SVR4
  36. #define IDENTITY(formal)\
  37.     formal
  38. #endif SVR4
  39. #ifndef SVR4
  40. #define CONCATENATE(formal1,formal2)\
  41.     IDENTITY(formal1)formal2
  42. #else SVR4
  43. #define CONCATENATE(formal1,formal2)\
  44.         formal1##formal2
  45. #endif SVR4
  46.  
  47. #define    pkg_private    extern
  48.  
  49.  
  50. #ifdef USING_SETS
  51.         /* definitions for sets */
  52. #define    BITS_PER_CHAR        8    /* number of bits in a char */
  53. #define    MAX_SET_ELEMENTS    256    /* number of elements in a set */
  54. #define MAX_SET_BYTES        (1 + (MAX_SET_ELEMENTS / BITS_PER_CHAR))
  55.  
  56. struct set
  57. {
  58.    char bytes[MAX_SET_BYTES];
  59. };
  60.  
  61. typedef struct set SET;
  62.  
  63. #ifdef OW_I18N
  64. #define    BYTE(n)        ((unsigned char)(n) >> 3) /* byte for element n */
  65. #else
  66. #define    BYTE(n)        ((unsigned)(n) >> 3)    /* byte for element n */
  67. #endif
  68. #define    BIT(n)        ((n) & 07)        /* bit in byte for element n */
  69.  
  70. #define    ADD_ELEMENT(set, n)    (set)->bytes[BYTE(n)] |= (1 << BIT(n))
  71. #define    REMOVE_ELEMENT(set, n)    (set)->bytes[BYTE(n)] &= ~(1 << BIT(n))
  72.  
  73. #define IN(set, n)   (((unsigned)((set)->bytes[BYTE(n)]) >> (int)BIT(n)) & 01)
  74.  
  75. #define    CLEAR_SET(set)    XV_BZERO((set)->bytes, MAX_SET_BYTES)
  76.  
  77. #define FILL_SET(set)    { register int i;\
  78.               for (i = 0; i < MAX_SET_BYTES; i++)\
  79.                 (set)->bytes[i] = 0xFF;\
  80.             }
  81. #endif
  82.  
  83. #ifdef XV_DEBUG
  84. #define AN_ERROR(expr)    ((expr) && take_breakpoint())
  85. #define ASSERT(expr)    if (expr) {} else abort()
  86. #define ASSUME(expr)    if (expr) {} else take_breakpoint()
  87. #else
  88. #define AN_ERROR(expr)    (expr)
  89. #define ASSERT(expr)
  90. #define ASSUME(expr)
  91. #endif
  92.  
  93. #endif
  94.